package com.atguigu.yygh.order.config;

import com.atguigu.yygh.mq.MqConst;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

/**
 * @description:生产者—————————————————————————————————以前的做法---------
 * @author :又菜又爱玩的→速趴塞亚锦←
 * @create :2023/5/20
 * @param  :1.8
 */
//@Configuration     生产者—————————————————————————————————以前的做法---------
public class OrderConfig {

    @Bean
    public Exchange getExchange(){//交换机
        return ExchangeBuilder.directExchange(MqConst.EXCHANGE_DIRECT_ORDER).durable(true).build();
    }
    @Bean
    public Queue getQueue(){//队列
        return QueueBuilder.durable(MqConst.QUEUE_ORDER).build();
    }
    @Bean//绑定
    public Binding binding(@Qualifier("getQueue") Queue queue,@Qualifier("getExchange") Exchange exchange){
       return BindingBuilder.bind(queue).to(exchange).with(MqConst.ROUTING_ORDER).noargs();
    }
}



